home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F26642_CallTemplatesByName.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  3.4 KB  |  102 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XSLT
  4.   Sub-category:   xsl:call-template
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylesheet demonstrates the use of xsl:call-template
  10.     by calling multiple templates by name to display different
  11.     HTML views of xslt output.
  12. ================================================================ -->
  13. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  14.   <xsl:output method="html" />
  15.  
  16.   <xsl:template match="/">
  17.     <html>
  18.       <head>
  19.         <title>Stylesheet Example</title>
  20.         <style type="text/css"><![CDATA[
  21.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  22.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  23.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  24.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  27.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  28.         TR { background-color: beige; }
  29.         BODY { background-color: beige; }
  30.         ]]></style>
  31.       </head>
  32.       <body>
  33.         <h1>Employee information sorted by Name and by Hourly rate.</h1>
  34.  
  35.         <!-- The second template that we call displays the employees in employee name order -->
  36.         <xsl:call-template name="ShowEmployeesByName" />
  37.  
  38.         <!-- The second template that we call displays the employees in order of Hourly Rate -->
  39.         <xsl:call-template name="ShowEmployeesByRate" />
  40.       </body>
  41.     </html>
  42.   </xsl:template>
  43.  
  44.   <xsl:template name="ShowEmployeesByName">
  45.     <h2>Employees sorted by Name</h2>
  46.     <!-- Table Header Creation -->
  47.     <table border="1">
  48.       <tr>
  49.         <th>Name</th>
  50.         <th>Department</th>
  51.         <th>Hourly Rate</th>
  52.         <th>Primary Language</th>
  53.       </tr>
  54.       <xsl:for-each select="employees/employee">
  55.         <xsl:sort order="ascending" select="employeename" />
  56.         <tr>
  57.           <td>
  58.             <xsl:value-of select="employeename" />
  59.           </td>
  60.           <td>
  61.             <xsl:value-of select="department" />
  62.           </td>
  63.           <td>
  64.             <xsl:value-of select="hourlyrate" />
  65.           </td>
  66.           <td>
  67.             <xsl:value-of select="primarylanguage" />
  68.           </td>
  69.         </tr>
  70.       </xsl:for-each>
  71.     </table>
  72.   </xsl:template>
  73.  
  74.   <xsl:template name="ShowEmployeesByRate">
  75.     <h2>Employees sorted by hourly rate</h2>
  76.     <table border="1">
  77.       <tr>
  78.         <th>Name</th>
  79.         <th>Department</th>
  80.         <th>Hourly Rate</th>
  81.         <th>Primary Language</th>
  82.       </tr>
  83.       <xsl:for-each select="employees/employee">
  84.         <xsl:sort order="ascending" select="hourlyrate" data-type="number" />
  85.         <tr>
  86.           <td>
  87.             <xsl:value-of select="employeename" />
  88.           </td>
  89.           <td>
  90.             <xsl:value-of select="department" />
  91.           </td>
  92.           <td>
  93.             <xsl:value-of select="hourlyrate" />
  94.           </td>
  95.           <td>
  96.             <xsl:value-of select="primarylanguage" />
  97.           </td>
  98.         </tr>
  99.       </xsl:for-each>
  100.     </table>
  101.   </xsl:template>
  102. </xsl:stylesheet>